package com.shenjies88.practice.baseframework.config;

import lombok.AllArgsConstructor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author by shenjies88
 * @since 2025/9/14 9:40
 */
@AllArgsConstructor
@Configuration
public class ChatMemoryConfig {

    private final JdbcChatMemoryRepository jdbcChatMemoryRepository;

    @Bean
    public ChatMemory jdbcChatMemory() {
        return MessageWindowChatMemory.builder()
                .chatMemoryRepository(jdbcChatMemoryRepository)
                .maxMessages(10)
                .build();
    }
}
